from pyspark import SparkConf, SparkContext
import os
os.environ['PYSPARK_PYTHON'] = r"D://Python/Python3107/python.exe"

conf = SparkConf().setMaster("local[*]").setAppName("test_spark")
sc = SparkContext(conf=conf)

rdd = sc.parallelize([('男', 100), ('女', 200), ('男', 300), ('女', 400)])
rdd2 = rdd.reduceByKey(lambda a, b: a + b)
print(rdd2.collect())

sc.stop()